package com.example.personal.mvvm.viewmodel

import androidx.lifecycle.MutableLiveData
import com.example.personal.api.PersonalApiManager
import com.example.personal.mvvm.bean.*
import com.gsafety.library.Base.BaseViewModel
import com.gsafety.libraryktx.expand.enqueue
import com.gsafety.libraryktx.manager.UserManager
import com.gsafety.libraryktx.net.api.request.RequestParamsManager


/**统计
 * @author : lj
 * @date : 2020/9/23 16:53
 */
class AnalyseViewModel: BaseViewModel(){
    var mCurrWarn = MutableLiveData<List<CurrWarningBean>>()
    var mHalfWarn = MutableLiveData<HalfWarningBean>()
    var mSpecialWarn = MutableLiveData<List<SpecialWarningBean>>()
    var mHalfTrend = MutableLiveData<List<HalfTrendBean>>()
    var mSpecialTrend = MutableLiveData<List<SpecialTrendBean>>()
    var mSpecialStatis = MutableLiveData<List<SpecialStatisBean>>()
    /**
     * 请求当前监测预警数量统计
     */
    fun requestCurrWarning(){
        var user=UserManager.getInstance().getUser()
        enqueue(PersonalApiManager.apiService.currWarningStatis(RequestParamsManager.currWarningStatis(user!!.orgType)),onSuccess={ result ->
            mCurrWarn.value=result
        },onFail={ error->
            mCurrWarn.value=null

        })
    }


    /**
     * 请求半年监测预警数量统计
     */
    fun requestHalfWarning(){
        var user=UserManager.getInstance().getUser()
        enqueue(PersonalApiManager.apiService.halfWarningStatis(RequestParamsManager.halfWarningStatis(user!!.orgType)),onSuccess={ result ->
            mHalfWarn.value=result
        },onFail={ error->
            mHalfWarn.value=null

        })
    }

    /**
     * 请求本月监测预警处置时长统计
     */
    fun requestspecialWarning(){
        var user=UserManager.getInstance().getUser()
        enqueue(PersonalApiManager.apiService.specialWarningStatis(RequestParamsManager.specialWarningStatis(user!!.orgType)),onSuccess={ result ->
            mSpecialWarn.value=result
        },onFail={ error->
            mSpecialWarn.value=null

        })
    }

    /**
     * 请求近半年监测预警趋势统计
     */
    fun requesthalfTrend(){
        var user=UserManager.getInstance().getUser()
        enqueue(PersonalApiManager.apiService.halfWarningTrend(RequestParamsManager.halfTrend(user!!.orgType)),onSuccess={ result ->
            mHalfTrend.value=result
        },onFail={ error->
            mHalfTrend.value=null

        })
    }

    /**
     * 请求当前各专项检测预警趋势统计
     */
    fun requestspecialTrend(){
        var user=UserManager.getInstance().getUser()
        enqueue(PersonalApiManager.apiService.specialTrend(RequestParamsManager.specialTrend(user!!.orgType)),onSuccess={ result ->
            mSpecialTrend.value=result
        },onFail={ error->
            mSpecialTrend.value=null

        })
    }

    /**
     * 请求当前各专项检测预警趋势统计
     */
    fun requestspecialStatis(){
        var user=UserManager.getInstance().getUser()
        enqueue(PersonalApiManager.apiService.specialStatis(RequestParamsManager.specialStatis(user!!.orgType)),onSuccess={ result ->
            mSpecialStatis.value=result
        },onFail={ error->
            mSpecialStatis.value=null

        })
    }
}